package com.example.zzm.yuejian03.Fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SearchView;

import com.example.zzm.yuejian03.Activity.PictureActivity;
import com.example.zzm.yuejian03.Activity.TrainActivity;
import com.example.zzm.yuejian03.Activity.TrainaActivity;
import com.example.zzm.yuejian03.Activity.TrainbActivity;
import com.example.zzm.yuejian03.Activity.TraincActivity;
import com.example.zzm.yuejian03.R;

public class CourseFragment extends BaseFragment {
    private View view;
    private ImageView imageView3,imageView6,imageView7,imageView8;
    private String[] mStrs = {"kk", "kk", "wskx", "wksx"};
    private SearchView mSearchView;
    private ListView lListView;


    @Override
    void initView() {
        imageView3 = (ImageView) view.findViewById(R.id.imageView3);
        imageView6 = (ImageView) view.findViewById(R.id.imageView6);
        imageView7 = (ImageView) view.findViewById(R.id.imageView7);
        imageView8 = (ImageView) view.findViewById(R.id.imageView8);
        mSearchView = (SearchView) view.findViewById(R.id.searchView);
        lListView = (ListView) view.findViewById(R.id.listView);
    }

    @Override
    void initEvent() {
        imageView8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), TrainActivity.class));
                //getActivity().onBackPressed();
            }
        });

        imageView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), TrainaActivity.class));
                //getActivity().onBackPressed();
            }
        });
        imageView6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), TrainbActivity.class));
                //getActivity().onBackPressed();
            }
        });
        imageView7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), TraincActivity.class));
                //getActivity().onBackPressed();
            }
        });
        mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            // 当点击搜索按钮时触发该方法
            @Override
            public boolean onQueryTextSubmit(String query) {
                return false;
            }

            // 当搜索内容改变时触发该方法
            @Override
            public boolean onQueryTextChange(String newText) {
                if (!TextUtils.isEmpty(newText)){
                    lListView.setFilterText(newText);
                }else{
                    lListView.clearTextFilter();
                }
                return false;
            }
        });

    }


    @Override
    void initData() {

    }

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view= inflater.inflate(R.layout.fragment_course,container,false);
        initData();
        initView();
        initEvent();
        //lListView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrs));
        lListView.setTextFilterEnabled(true);
        return  view;
    }

    public interface OnFragmentInteractionListener {
    }
}